<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    /* * {
        margin: 0;
        padding: 0;
        text-decoration: none;
        align-items: none;
    }

    .box {
        width: 100%;
        height: 800px;
        border: 1px solid#000;
        background-color: antiquewhite;
        margin: 0 auto;
        color: gray;
        display: flex;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        font-size: 80px;
    }

    .box img {
        width: 200px;
        height: 200px;
        border-radius: 50%;
        margin-bottom: 50px;


    } */
    *{
            margin: 0;
            padding: 0;
        }

        html,body{
            width: 100%;
            height: 100%;
            background-color: #ccc;
        }
        img{width: 200px;
            height: 200px;
            border-radius: 50%;
        }
        a{
            font-size: 30px;
        }
        div{
            text-align: center;
            padding-top: 200px;
            font-size: 80px;
            font-weight: 800;
            text-shadow: 1px 1px 0 #000,-1px -1px 0 #fff;
            color: #ccc;
        }
</style>

<body>
<!-- 
    <div class="box">
        <img src="../../../QQ图片20220920235645.jpg">
        <span id="Mochu">
        </span>
    </div> -->

    <div id="hezi">
        <a href="../../../c29530399922ea39349036f62f8f15b4.jpeg">点我</a>
        <img src="../../../QQ图片20220920235645.jpg">
        <p>距离双十一还有</p>
        <span id="day"></span>天
        <span id="hours"></span>时
        <span id="minutes"></span>分
        <span id="seconds"></span>秒
    </div>
    <script>
        // window.onload = function countTime() {
        //     var date = new Date();
        //     var now = date.getTime();
        //     var str = "2022/11/11 00:00:00";
        //     var endDate = new Date(str);
        //     var end = endDate.getTime();
        //     var leftTime = end - now;
        //     var d, h, m, s;
        //     d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
        //     h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
        //     m = Math.floor(leftTime / 1000 / 60 % 60);
        //     s = Math.floor(leftTime / 1000 % 60)
        //     if (leftTime > 1) {
        //         document.getElementById("Mochu").innerHTML = "   距  离   双  十   一  还   有  ：<br><span class='Mochu'> " +
        //             d + "</span> 天<span class='Mochu'> " + "0" + h
        //             + "</span> 时<span class='Mochu'> " + m + "</span> 分<span class='Mochu'> " + s + "</span> 秒";
        //     } else {
        //         document.getElementById("Mochu").innerHTML = "<span class='Mochu'>活动已结束</span>";
        //     }
        //     setTimeout(countTime, 1000);
        // }
        // function randomColor() {
        //     let arr = [];
        //     for (let i = 0; i < 3; i++) {
        //         arr.push(randomNum(0, 255));
        //     }
        //     return 'rgb(' + arr.join() + ')'
        // }
        function diffTime(curr, tar) {
            let diffMs = Math.ceil((tar.getTime() - curr.getTime())) / 1000;
            return {
                day: Math.floor(diffMs / (60 * 60 * 24)),
                hours: Math.floor(diffMs % (60 * 60 * 24) / (60 * 60)),
                minutes: Math.floor(diffMs % (60 * 60) / 60),
                seconds: Math.floor(diffMs % 60)
            }
        }
        function randomNum(a, b) {
            let max = Math.max(a, b);
            let min = Math.min(a, b);
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
        function randomColor() {
            let arr = [];
            for (let i = 0; i < 3; i++) {
                arr.push(randomNum(0, 255));
            }
            return 'rgb(' + arr.join() + ')'
        }
        let target = new Date(2022, 10, 11, 00, 00, 00);

        setInterval(function () {
            // 获取现在的时间
            let current = new Date()

            let diff = diffTime(current, target);

            document.body.style.backgroundColor = randomColor()
            hezi.style.color = randomColor()

            day.innerText = diff.day
            hours.innerText = diff.hours
            minutes.innerText = diff.minutes
            seconds.innerText = diff.seconds
        }, 1000)
    </script>
</body>

</html>